package com.cb.common.webService;

import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.transport.http.gzip.GZIPInInterceptor;
import org.apache.cxf.transport.http.gzip.GZIPOutInterceptor;

import com.cb.common.util.ConfigUtil;



public class ClientService<T>  {
	
	@SuppressWarnings("unchecked")
	public T getClient(String wsConfig,Class<T> class1){
		
		String address = ConfigUtil.getInstance().getXmlValByStr(wsConfig, "http://183.63.31.25:38080/WebABE.asmx");
//			address="http://183.63.31.25:38080/WebABE.asmx";
		JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();

		
		/*factory.getInInterceptors().add(new LoggingInInterceptor());  
		factory.getOutInterceptors().add(new LoggingOutInterceptor());  
		factory.getInInterceptors().add(new GZIPInInterceptor());  
		factory.getOutInterceptors().add(new GZIPOutInterceptor());  
*/
	/*	System.setProperty("http.proxySet", "true");
        System.setProperty("http.proxyHost", "10.123.74.137");
        System.setProperty("http.proxyPort", "808");*/
		
		// 注册WebService接口
		factory.setServiceClass(class1);
		// 设置WebService地址
		factory.setAddress(address);
        
		T object =  (T) factory.create();
		return object;
	}


}
